class Solution:
    def numSteps(self, s: str) -> int:
        num = int(s, 2)
        def f(n):
            if n == 1: return 0
            if n == 2: return 1
            if n & 1:
                return 1 + f(n+1)
            return 1 + f(n >> 1)
        return f(num)

if __name__ == '__main__':
    s  =Solution()
    r = s.numSteps("1101")